<template>
    <div>
        <!-- <qrcode value="Hello, World!" :options="{ width: 200 }"></qrcode> -->
        <vue-qrcode :value="qrcode+guid" :options="{ width: 400 }"></vue-qrcode>
    </div>
</template>

<script>
import VueQrcode from "@chenfengyuan/vue-qrcode";
import { getcode } from "@/api/upload";
export default {
  components: { VueQrcode },
  data() {
    return {
      guid: "",
      qrcode: "http://localhost:9527/#/example/qrcode?"
    };
  },
  created() {
    this.guid = this.newGuid();
  },
  methods: {
    addrequrest() {
      getcode().then(response => {
        //未获取到图片地址
        if (response == 0) {
          addrequrest();
        } else if (response === 1) {
          //图片地址
        }
      });
    },
    newGuid() {
      var guid = "";
      for (var i = 1; i <= 32; i++) {
        var n = Math.floor(Math.random() * 16.0).toString(16);
        guid += n;
        if (i == 8 || i == 12 || i == 16 || i == 20) guid += "-";
      }
      return guid;
    }
  }
};
</script>

<style scoped>
</style>